const { axios } = require('../../utils/http')
Page({
  data: {
    userList: [],
    managerInfo: {},
    userInfo: {},
    active: 2
  },
  onShow() {
    if (typeof this.getTabBar === 'function' && this.getTabBar()) {
      this.getTabBar().setData({
        active: 2
      })
    }
    this.getUserList()
    this.getBestUser()
    this.getUserInfo()
  },
  getUserInfo() {
    const userInfo = wx.getStorageSync('userInfo')
    this.setData({
      userInfo
    })
  },
  getUserList() {
    axios.get('/chat/lastSearch').then(res => {
      console.log(res)
      res.data.error === -1 &&
        this.setData({
          userList: res.data.data
        })
    })
  },
  getBestUser() {
    axios.post('/user/manager').then(res => {
      this.setData({
        managerInfo: res.data.data
      })
    })
  }
})
